﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="admin_del.aspx.cs" Inherits="admin_admin_del" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>删除项目</title>
<link href="../css/admin_del_style.css" rel="stylesheet" type="text/css" />
<script  type="text/javascript" src="../js/jquery.js"></script>
<script>

$(".leftsidebar_box dt").css({"background-color":"#538ed7"});
$(".leftsidebar_box dt img").attr("src","images/left/select_xl01.png");
$(function(){
	$(".leftsidebar_box dd").hide();
	$(".leftsidebar_box dt").click(function(){
		$(".leftsidebar_box dt").css({"background-color":"#538ed7"})
		$(this).css({"background-color": "#317eb4"});
		$(this).parent().find('dd').removeClass("menu_chioce");
		$(".leftsidebar_box dt img").attr("src","images/left/select_xl01.png");
		$(this).parent().find('img').attr("src","images/left/select_xl.png");
		$(".menu_chioce").slideUp(); 
		$(this).parent().find('dd').slideToggle();
		$(this).parent().find('dd').addClass("menu_chioce");
	});
})
</script>
<body>
    <form id="form1" runat="server">
<div id="top"></div>
<div id="main">
	<div id="main_top">
    	杭州科技职业技术学院”网页设计“技能大赛
    </div>
    <div id="main_button">
    	<div id="main_1">
    		<div id="main_1_1" ></div>
        	<div id="main_1_2">
                <font face="Wingdings" color="#666666">v</font><a href="#" style="text-decoration:none;">查看结果</a>
                <font face="Wingdings" color="#666666">v</font><a href="#" style="text-decoration:none;">我要投票</a>
                <font face="Wingdings" color="#666666">v</font><a href="#" style="text-decoration:none;">管理员登录</a>>>删除</div>
    		</div>
    	<div id="main_2"></div>
        <div id="content"> 
        	<div class="list left">
	 
                <div class="container">
                <div class="leftsidebar_box">
                  <div class="line"></div>
                    <dl>
                        <dt>个人资料<img src="../pic/select_xl01.png" width="5" height="8" /></dt>
                        <dd><a href="./admin_changepwd.aspx">修改登录密码</a>
                    </dl>
                
                        <dt>参赛资料<img src="../pic/select_xl01.png" width="5" height="8" />
                            <dd><a href="./admin_add.aspx">添加参赛项目</a>
                            <dd><a href="./admin_del.aspx">删除参赛项目</a>           
                        </dt>     	
                    </dl>
                    
                </div>
            
            	</div>
			</div>  
        	<div id="content_t">
                <br/><br/>
                		<font face="Wingdings" color="#666666">v</font>删除参赛选手及其项目</p>
                		<p>&nbsp;</p>
          				<div>
          				  <p><span>　参赛人及项目：</span>
          				    <select id="webList" name="webid">
       				        </select>
       				      </p>
          				  <p>&nbsp;</p>
          				</div><br/>
               			<div><input type="button" value="删除" id="btnSubmit"/></div><br/>
            </div>
        </div>
       	<div id="main_3">
        	<div id="main_3_1"> 
            </div>
            <div id="main_3_2">
            	<hr color="#565656" />
            </div>
        </div>
        <div id="main_4">Copyright 2015 在线投票 jj.948500953.Timu</div>
  	</div>
</div>
<div id="foot"></div>
    </form>
    <script src="https://cdn.bootcss.com/babel-standalone/6.23.1/babel.min.js" type="text/javascript"></script>
    <script type="text/javascript">
            // 表单提交数据
        document.querySelector("#btnSubmit").onclick = function (){
        
            var formData = new FormData();
            formData.append('webid',form1.webid.value);
            
            
            var xhr = new XMLHttpRequest();

            xhr.onreadystatechange  = function (){
                if ( xhr.readyState == 4 && xhr.status == 200 ) {
                    console.log( xhr.response );
                    if( xhr.response > 0) {
                        alert("删除成功!");
                         window.location.href = "admin_del.aspx";
                    } else {
                        alert("删除失败");
                    }
                    getList();
                } else {
                    console.warn(xhr.statusText);
                }
            }

            xhr.open('POST', '../api/delProj.ashx');
            xhr.send(formData);
            // console.log(formData);
                
        }
                    // 显示可选网站
        window.onload = function (){
            getList();
        }
        
        function getList(){
       
            var xhr = new XMLHttpRequest();

                xhr.onreadystatechange  = function (){
                    if ( xhr.readyState == 4 && xhr.status == 200 ) {
                        console.log( xhr.response );
                        renderData(JSON.parse(xhr.response))
                        
                    } else {
                        console.warn(xhr.statusText);
                    }
                }

                xhr.open('POST', '../api/getList.ashx');
                xhr.send();
                // console.log(formData);
        }
        
        function renderData(source){
            var str = "";
            source.data.forEach(function (item, index){
                str+="<option value=\""+item.id+"\">"+item.maker+"|"+item.webname+"</option>"
            })
            document.querySelector("#webList").innerHTML = str;
        }
    </script>
</body>
</html>
